#include<iostream>
#include<cstdio>

using namespace std;

const int N = 100010, M = 1000010;

int n, m;
int ne[N];
char s[M], p[N];

int main(){
	cin >> n >> p + 1 >> m >> s + 1;
	//找next数组过程 
	for (int i = 2, j = 0; i <= n; i ++ )
    {
        while (j && p[i] != p[j + 1]) j = ne[j];
        if (p[i] == p[j + 1]) j ++ ;
        ne[i] = j;
    }  
	//匹配字符串过程
	for(int i = 1, j = 0; i <= m; i ++ ){
		while(j && s[i] != p[j + 1]) j = ne[j];
		if(s[i] == p[j + 1]) j ++ ;
		if(j == n){
			printf("%d ", i - n);
			j = ne[j];
		}
	}  
	return 0;
}
